/**
 * Define routes/RESTServices for users namespace
 * Version: v1.0
 */

//401: failed
//200: OK

module.exports = function (app) {
    var users = require('../controllers/user-controller');
    logger.debug("load the user-route module....");
    /**
     * 用户相关的服务
     */
    app.post('/rest/' + RESTFullServiceVersion + '/users/signup/:deviceId', users.registerUser);
    app.get('/rest/' + RESTFullServiceVersion + '/users/bindClientId/:clientId/:token/:deviceId', users.bindClientId);
    app.post('/rest/' + RESTFullServiceVersion + '/users/login/:deviceId', users.login);
    app.post('/rest/' + RESTFullServiceVersion + '/users/appLogin/:deviceId', users.appLogin);

    /*  宝宝树66小区二次改造    add   guo.xiaomin  20170925  start   */
    app.post('/rest/' + RESTFullServiceVersion + '/users/appMtLogin/:deviceId', users.appMtLogin);
    /*  宝宝树66小区二次改造    add   guo.xiaomin  20170925  end   */

    app.post('/rest/' + RESTFullServiceVersion + '/users/appThirdPartyLogin/:thirdId/:deviceId', users.appThirdPartyLogin);
    //获取用户权限列表
    app.get('/rest/' + RESTFullServiceVersion + '/users/getUserAuthList/:token/:deviceId', users.getUserAuthList);

    /*  宝宝树66小区二次改造    add   guo.xiaomin  20170802   start   */
    app.get('/rest/' + RESTFullServiceVersion + '/users/getUserGagOrNot/:token/:deviceId', users.getUserGagOrNot);
    /*  宝宝树66小区二次改造    add   guo.xiaomin  20170802   end   */

    /*  宝宝树66小区二次改造    add   guo.xiaomin  20170919   start   */
    app.post('/rest/' + RESTFullServiceVersion + '/users/isBabyTreeUser/:deviceId', users.isBabyTreeUser);
    /*  宝宝树66小区二次改造    add   guo.xiaomin  20170919   end   */

    app.get('/rest/' + RESTFullServiceVersion + '/users/logout/:userId/:token/:deviceId', users.logout);
    app.get('/rest/' + RESTFullServiceVersion + '/users/findById/:userId/:token/:deviceId', users.findById);
    app.put('/rest/' + RESTFullServiceVersion + '/users/updateUser/:userId/:token/:deviceId', users.updateUser);
    app.get('/rest/' + RESTFullServiceVersion + '/users/generateVerificationCode/:mobilePhone/:flag/:deviceId', users.generateVerificationCode);
    app.post('/rest/' + RESTFullServiceVersion + '/users/uploadProfileImage/:userId/:token/:deviceId', users.uploadUserProfileImage);
    //app.get('/rest/' + RESTFullServiceVersion + '/users/getProfileImage/:userId/:token', users.getUserProfileImage);
    app.get('/rest/' + RESTFullServiceVersion + '/users/checkVerificationCode/:mobilePhone/:verificationCode/:deviceId', users.checkVerificationCode);
    app.get('/rest/' + RESTFullServiceVersion + '/users/resetPassword/:mobilePhone/:newPassword/:deviceId', users.resetPassword);
    app.put('/rest/' + RESTFullServiceVersion + '/users/changePassword/:token/:userName/:deviceId', users.changePassword);

    /*  宝宝树66小区五期安全漏洞    add  登陆极验证 guo.xiaomin  20171116   start   */
    // 1120-commit-master
    app.get('/rest/' + RESTFullServiceVersion + '/users/geetest/captchChangePassword/:token/:deviceId', users.captchChangePassword); // 修改密码极验证1次
    app.post('/rest/' + RESTFullServiceVersion + '/users/geetest/captchValidateChangePassword/:token/:deviceId', users.captchValidateChangePassword); // 修改密码极验证2次
    app.post('/rest/' + RESTFullServiceVersion + '/users/sms/getSmsCodeChangePwd/:token/:deviceId', users.getSmsCodeChangePwd); // 获取验证码
    app.post('/rest/' + RESTFullServiceVersion + '/users/changePasswordNew/:token/:userName/:deviceId', users.changePasswordNew); // 真正修改密码

    app.post('/rest/' + RESTFullServiceVersion + '/users/resetApplyStatus/:token/:deviceId', users.resetApplyStatus); // 重置申请状态
    /*  宝宝树66小区五期安全漏洞    add  登陆极验证 guo.xiaomin  20171116   end   */

    app.put('/rest/' + RESTFullServiceVersion + '/users/setUserCommunityOld/:userId/:token/:deviceId', users.setUserCommunity);
    //新设置小区接口 1.1.2
    app.get('/rest/' + RESTFullServiceVersion + '/users/setUserCommunityNew/:communityId/:token/:deviceId', users.setUserCommunityNew);

    //2.0用户新增小区
    app.get('/rest/' + RESTFullServiceVersion + '/users/addCommunity/:communityId/:token/:deviceId', users.addCommunity);
    app.get('/rest/' + RESTFullServiceVersion + '/users/userCommunityList/:token/:deviceId', users.getUserCommunityList);
    /*  宝宝树66小区二次改造    add  小区切换 luolh  20170803   start   */
    app.get('/rest/' + RESTFullServiceVersion + '/users/ambassadorCommunityList/:token/:deviceId', users.getAmbassadorCommunityList);
    /*  宝宝树66小区二次改造    add  小区切换 luolh  20170803   end   */
    //opm-v2 调用
    app.get('/rest/' + RESTFullServiceVersion + '/backOffice/setUserCommunity/:communityId/:userId', users.backSetUserCommunity);
    app.get('/rest/' + RESTFullServiceVersion + '/backOffice/initCommunity/:communityId', users.initCommunity);

    app.get('/rest/' + RESTFullServiceVersion + '/users/getContactList/:token/:deviceId', users.getContactList);
    app.put('/rest/' + RESTFullServiceVersion + '/users/addToContactList/:token/:userName/:userNameToAdd/:deviceId', users.addToContactList);
    app.delete('/rest/' + RESTFullServiceVersion + '/users/RemoveFromContactList/:token/:userName/:userNameToRemove/:deviceId', users.RemoveFromContactList);

    app.post('/rest/' + RESTFullServiceVersion + '/users/followup/:category/:id/:token/:deviceId', users.followup);
    app.put('/rest/' + RESTFullServiceVersion + '/users/cancelFollowup/:category/:id/:token/:deviceId', users.cancelFollowup);
    app.post('/rest/' + RESTFullServiceVersion + '/users/cancelFollowup/:category/:id/:token/:deviceId', users.cancelFollowup);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getFollowupList/:category/:pageNo/:token/:deviceId', users.getFollowupList);

    app.get('/rest/' + RESTFullServiceVersion + '/users/getNeighbourList/:pageNo/:token/:deviceId', users.getNeighbourList);
    app.post('/rest/' + RESTFullServiceVersion + '/users/applyToBeExpert/:token/:deviceId', users.applyToBeExpert);

    app.post('/rest/' + RESTFullServiceVersion + '/users/loginViaWeChat/:wechatId/:deviceId', users.loginViaWeChat);

    app.get('/rest/' + RESTFullServiceVersion + '/users/findUser/:id/:deviceId', users.findUser);

    app.get('/rest/' + RESTFullServiceVersion + '/users/getUserProfile/:userId/:token/:deviceId', users.getUserProfile);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getUserQuestionList/:pageNo/:userId/:token/:deviceId', users.getUserQuestionList);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getUserQuestionListNew/:pageNo/:userId/:token/:deviceId', users.getUserQuestionListNew);

    app.get('/rest/' + RESTFullServiceVersion + '/users/getHomePage/:token/:deviceId', users.getHomePage);
    app.get('/rest/' + RESTFullServiceVersion + '/users/checkToken/:token/:deviceId', users.checkToken);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getUserQuestionStatistics/:userId/:token/:deviceId', users.getUserQuestionStatistics);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getFollowupUsers/:token/:deviceId', users.getFollowupUsers);
    app.post('/rest/' + RESTFullServiceVersion + '/users/authenticateUser/:token/:deviceId', users.authenticateUser);
    app.post('/rest/' + RESTFullServiceVersion + '/users/authenticateUserByPromotionCode/:token/:deviceId', users.authenticateUserByPromotionCode);

    app.get('/rest/' + RESTFullServiceVersion + '/users/getUserAuthenticationStatus/:token/:deviceId', users.getUserAuthenticationStatus);

    app.get('/rest/' + RESTFullServiceVersion + '/users/getUserInvitedCode/:token/:deviceId', users.getUserInvitedCode);
    //我的福利
    app.get('/rest/' + RESTFullServiceVersion + '/users/getMyVoucherList/:token/:deviceId', users.getMyVoucherList);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getVoucherDetail/:voucherId/:token/:deviceId', users.getVoucherDetail);

    //根据页码显示全部用户
    app.get('/rest/' + RESTFullServiceVersion + '/users/getAllUser/:pageNo', users.getAllUser);

    //根据用户名和电话显示全部用户
    //app.post('/rest/' + RESTFullServiceVersion + '/users/findByNameORPhone/:pageNo', users.findByNameORPhone);

    //后台创建用户
    app.post('/rest/' + RESTFullServiceVersion + '/users/generateUser', users.registerUserFromBackOffice);

    //后台管理用户路由
    app.post('/rest/' + RESTFullServiceVersion + '/users/searchUser/:pageNo', users.searchBackOfficeUser);

    //后台用户登录路由
    app.post('/rest/' + RESTFullServiceVersion + '/backoffice/login', users.adminLogin);
    app.post('/rest/' + RESTFullServiceVersion + '/backoffice/users/examineUserAuthenticate', users.examineUserAuthenticate);
    app.post('/rest/' + RESTFullServiceVersion + '/backoffice/users/refuseUserAuthenticate/:id', users.refuseUserAuthenticate);
    app.get('/rest/' + RESTFullServiceVersion + '/backoffice/users/getAuthenticationUserList/:nickname/:communityId/:status/:page', users.getAuthenticationUserList);
    //文件存储到mongoDB GridFS中
    //app.post('/rest/'+RESTFullServiceVersion+'/users/uploadUserProfileImage/:userId/:token',users.uploadUserProfileImage);
    //app.get( '/rest/'+RESTFullServiceVersion+'/users/getUserProfileImage/:userId/:token',users.getUserProfileImage);


    app.get('/generateVoucher/:userId', users.generateVoucher);


    //1.5.0
    app.get('/rest/' + RESTFullServiceVersion + '/users/getRecentContactPerson/:token/:deviceId', users.getRecentContactPerson);

    app.get('/rest/' + RESTFullServiceVersion + '/users/homePageBanner/:token/:deviceId', users.homePageBanner);
    app.get('/rest/' + RESTFullServiceVersion + '/users/homePageFreshNews/:token/:deviceId', users.homePageFreshNews);
    app.get('/rest/' + RESTFullServiceVersion + '/users/homePageQuestionAndActivity/:token/:deviceId', users.homePageQuestionAndActivity);
    app.get('/rest/' + RESTFullServiceVersion + '/users/homePageTopics/:token/:deviceId', users.homePageTopics);

    app.get('/rest/' + RESTFullServiceVersion + '/users/randomSetCommunity/:token/:deviceId', users.randomSetCommunity);
    app.get('/rest/' + RESTFullServiceVersion + '/users/homePageRank/:token/:pageNo/:deviceId', users.getScoreRank);
    app.get('/rest/' + RESTFullServiceVersion + '/users/userSignIn/:token/:deviceId', users.userSignIn);

    //1.6.0
    app.post('/rest/' + RESTFullServiceVersion + '/users/resetUserPassword/:deviceId', users.resetUserPassword);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getMyAppStatistics/:token/:deviceId', users.getMyAppStatistics);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getMyFollowupUsers/:ts/:token/:deviceId', users.getMyFollowupUsers);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getMyBeFollowedUsers/:ts/:token/:deviceId', users.getMyBeFollowedUsers);
    app.get('/rest/' + RESTFullServiceVersion + '/users/getMyUnreadMessageCount/:token/:deviceId', users.getMyUnreadMessageCount);

    app.get('/rest/' + RESTFullServiceVersion + '/users/otherUserPage/:userId/:token/:deviceId', users.otherUserPage);

    //2.0他人页信接口
    app.get('/rest/' + RESTFullServiceVersion + '/users/otherUserPageNew/:userId/:token/:deviceId', users.otherUserPageNew);
    app.get('/rest/' + RESTFullServiceVersion + '/users/otherUserProfile/:userId/:token/:deviceId', users.otherUserProfile);

    //1.7.0
    app.post('/rest/' + RESTFullServiceVersion + '/users/image/:token/:deviceId', users.uploadUserImage);
    app.post('/rest/' + RESTFullServiceVersion + '/users/authentication/:token/:deviceId', users.postUserAuthenticationData);
    app.get('/rest/' + RESTFullServiceVersion + '/users/doSomethingList/:token/:deviceId', users.getWantDoSomethingList);
    app.post('/rest/' + RESTFullServiceVersion + '/users/want/:token/:deviceId', users.postUserWant);
    app.post('/rest/' + RESTFullServiceVersion + '/users/wantUsers/:ts/:token/:deviceId', users.getSameWantUserList);
    app.post('/rest/' + RESTFullServiceVersion + '/users/wantRecommendUgc/:token/:deviceId', users.getWantRecommendUgc);
    app.get('/rest/' + RESTFullServiceVersion + '/users/push/wantPage/:mapId/:token/:deviceId', users.getUserWantPage);
};
